<template>
  <div style="">
    <Header :left="true" leftText="返回" title="产品外观检测"> </Header>
    <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
      left-icon="description">基本信息</NoticeBar>
    <van-form :style="autoHeight" @submit="onSubmit">
      <van-field required readonly class="formstyle" name="picker" :value="valueteamid" label="班组" placeholder="点击选择班组"
        @click="showPickerteamid = true" />
      <van-popup v-model="showPickerteamid" position="bottom">
        <van-picker show-toolbar :columns="columnsteamId" @confirm="onConfirmteamid" @cancel="showPickerteamid = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.teamName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <van-field required readonly class="formstyle" name="picker" :value="valuepShiftName" label="班次"
        placeholder="点击选择班次" @click="showPickerpShiftID = true" />
      <van-popup v-model="showPickerpShiftID" position="bottom">
        <van-picker show-toolbar :columns="columnsshift" @confirm="onConfirmpShiftID"
          @cancel="showPickerpShiftID = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.pshiftname }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>

      <!-- <van-field required readonly class="formstyle" name="picker" :value="valueTimeRange" label="时间范围"
        placeholder="点击选择间范围" @click="showPickerTimeRangeName = true" /> -->
      <van-field required readonly class="formstyle" name="picker" :value="valueTimeRange" label="时间范围" />
      <van-popup v-model="showPickerTimeRangeName" position="bottom">
        <van-picker show-toolbar :columns="columnsTimeRangeName" @confirm="onConfirmTimeRange"
          @cancel="showPickerTimeRangeName = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.TimeRangeName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>

      <!-- <div v-show="ddd1">
        <van-row v-show="van1" gutter="20" style="margin-top: 5px">
          <van-col span="10">
            <van-field class="formstyleplus" readonly name="picker" :value="valueTimeRange11" placeholder="选择时间"
              @click="showPickerTimeRangeName11 = true" />
            <van-popup v-model="showPickerTimeRangeName11" position="bottom">
              <van-picker show-toolbar :columns="columnsTimeRangeName11" @confirm="onConfirmTimeRange11"
                @cancel="showPickerTimeRangeName11 = false">
                <template #option="option">
                  <div style="display: flex; flex-direction: column; align-items: center">
                    <div>{{ option.TimeRangeName }}</div>
                  </div>
                </template>
              </van-picker>
            </van-popup>
          </van-col>
          <van-col span="2" class="formstyleplus">
            ～
          </van-col>
          <van-col span="10">
            <van-field readonly class="formstyleplus" :value="valueTimeRange22" />
          </van-col>
        </van-row>
      </div> -->

      <van-field required readonly clickable class="formstyle" name="datetimePicker" :value="form.ProductionDate"
        label="生产日期" placeholder="点击选择日期" @click="ShowPickerdatetime" />
      <van-popup v-model="showPickerdatetime" position="bottom">
        <van-datetime-picker type="datetime" @confirm="onConfirmdatetime" @cancel="showPickerdatetime = false"
          :min-date="minDate" :max-date="maxDate" />
      </van-popup>

      <van-field required readonly class="formstyle" label="抽检时间" v-model="form.planworkdatetime" placeholder="" />

      <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
        left-icon="description">产品信息</NoticeBar>
      <van-field class="formstyle" :value="Number(form.pOrderID)" name="订单号码" label="订单号码" placeholder="输入订单号码" />
      <van-field class="formstyle" v-model="form.materialname" name="产品名称" label="产品名称" placeholder="输入产品名称" />

      <van-field class="formstyle" v-model="form.materialid" name="产品代码" label="产品代码" placeholder="请填写产品代码"
        :rules="[{ required: false, message: '请填写产品代码' }]" />

      <van-field class="formstyle" v-model="plineID" name="生产线代码" label="生产线代码" placeholder="输入生产线代码" />

      <van-field required readonly class="formstyle" name="picker" :value="userName" label="客户名称" placeholder="点击选择客户"
        @click="showPickerUser = true" />
      <van-popup v-model="showPickerUser" position="bottom">
        <van-picker show-toolbar :columns="columnsUser" @confirm="onConfirmUser" @cancel="showPickerUser = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.userName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <van-field class="formstyle" v-model="form.BatchID" name="生产批次" label="生产批次" placeholder="请填写生产批次"
        :rules="[{ required: false, message: '请填写生产批次' }]" />


      <van-field required readonly class="formstyle" name="picker" :value="CheckTypeName" label="检验类型" v-show="ddd"
        placeholder="点击选择检验类型" @click="showPickerType = true" />
      <van-popup v-model="showPickerType" position="bottom">
        <van-picker show-toolbar :columns="columnsType" @confirm="onConfirmtype" @cancel="showPickerType = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.CheckTypeName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>

      <van-field readonly class="formstyle" :value="CheckTypeNameplus" label="加严项名称" v-show="eee"
        placeholder="点击选择加严项名称" />


      <div v-show="fff">
        <van-field required name="包装单位" class="formstyle" label="包装单位">
          <template #input>
            <van-radio-group v-model="checked" direction="horizontal" @change="changeQC">
              <van-radio name="1">箱</van-radio>
              <van-radio name="0">垛</van-radio>
            </van-radio-group>
          </template>
        </van-field>

        <van-field v-show="ddd2" class="formstyle" v-model="form.CountPerBox" name="每箱数量" label="每箱数量" placeholder="请填写箱数"
          use-extra-slot>
          <van-extra slot="extra">PC</van-extra>
        </van-field>

        <van-field v-show="!ddd2" class="formstyle" v-model="form.CountPerBox" name="每垛数量" label="每垛数量"
          placeholder="请填写垛数" use-extra-slot>
          <van-extra slot="extra">PC</van-extra>
        </van-field>

        <!-- <van-field v-show="ddd2" required class="formstyle" v-model="form.ProductionAmount2" name="箱数/垛" label="箱数/垛"
          placeholder="请先填写箱数/垛" use-extra-slot @input="setNotice4">
        </van-field> -->

        <van-field v-show="!ddd2" required class="formstyle" v-model="form.ProductionAmount1" name="层数/垛" label="层数/垛"
          placeholder="请先填写层数/垛" use-extra-slot @input="setNotice2">
        </van-field>

        <van-field v-show="ddd2" required class="formstyle" v-model="duonumber1" name="垛数" label="垛数" placeholder="请先填写垛数"
          use-extra-slot @input="setNotice3">
        </van-field>

        <van-field v-show="!ddd2" required class="formstyle" v-model="duonumber" name="垛数" label="垛数" placeholder="请先填写垛数"
          use-extra-slot @input="setNotice1">
        </van-field>
      </div>


      <div v-show="!fff">
        <div v-show="!ggg">
          <van-field class="formstyle" v-model="form.CountPerBox" name="每箱/垛数量" label="每箱/垛数量" placeholder="请填写箱/垛数量"
            use-extra-slot>
            <van-extra slot="extra">PC</van-extra>
          </van-field>

          <van-field class="formstyle" v-model="form.BoxInBatch" name="本批检验数量" label="本批检验数量" placeholder="请填写本批检验数量"
            use-extra-slot @input="setProductionAmount">
            <van-extra slot="extra">箱/垛</van-extra>
          </van-field>
        </div>
      </div>

      <div v-show="ggg">
        <van-field class="formstyle" v-model="form.CountPerBox1" name="每箱/垛数量" label="每箱/垛数量" placeholder="请填写箱/垛数量"
          use-extra-slot>
          <van-extra slot="extra">PC</van-extra>
        </van-field>

        <van-field class="formstyle" v-model="form.BoxInBatch1" name="本批检验数量" label="本批检验数量" placeholder="请填写本批检验数量"
          use-extra-slot @input="setNotice4">
          <van-extra slot="extra">箱/垛</van-extra>
        </van-field>
      </div>


      <van-field class="formstyle" v-model="form.PlanBox" name="计划抽样数量" label="计划抽样数量" placeholder="请填写计划抽样数量"
        :rules="[{ required: false, message: '请填写计划抽样数量' }]" use-extra-slot>
        <van-extra slot="extra">PC</van-extra>
      </van-field>
      <van-cell-group>
        <van-row type="flex">
          <van-col span="5" class="formstyle">
            <van-cell-group>
              <van-cell title="实际抽样数量" />
            </van-cell-group>
          </van-col>
          <van-col span="6">
            <van-field class="formstyle" v-model="form.SamplePerBox" input-align="right" name="每箱/垛抽检数量"
              placeholder="每箱/垛中抽样数量" @input="setNotice" />
          </van-col>
          <van-col span="1" class="formstyle">
            <van-cell-group>
              <van-cell title="/" />
            </van-cell-group>
          </van-col>
          <van-col span="12">
            <van-field class="formstyle" v-model="form.SampleBox" name="抽样箱/垛数量" placeholder="抽样箱/垛数量" use-extra-slot
              @input="setNotice">
              <van-extra slot="extra" v-if="form.SamplePerBox * form.SampleBox > 0">共计{{ form.SamplePerBox *
                form.SampleBox }}PC</van-extra>
            </van-field>
          </van-col>
        </van-row>
      </van-cell-group>

      <!-- <van-field class="formstyle" v-model="form.PlanBox" name="计划抽样数量" label="计划抽样数量" placeholder="请填写计划抽样数量"
        :rules="[{ required: false, message: '请填写计划抽样数量' }]" use-extra-slot>
        <van-extra slot="extra">PC</van-extra>
      </van-field> -->
      <van-field readonly required class="formstyle" v-model="placeholder" name="包装条码" label="包装条码"
        :rules="[{ required: false, message: '请填写包装条码' }]" right-icon="scan" @click="showScanner2">
      </van-field>

      <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
        left-icon="description">缺陷信息 - 严重缺陷</NoticeBar>
      <van-field class="formstyle" v-model="form.SamplePlan1Re" readonly name="抽样计划Re" label="抽样计划Re"
        placeholder="输入抽样计划Re=" />
      <van-field class="formstyle" v-model="form.SamplePlan1Value" required name="异常数量" label="异常数量" placeholder="输入异常数量"
        @input="isShowManageReasonNameMethod" />
      <van-field required readonly class="formstyle" name="picker" :value="ManageReasonName1" label="缺陷类型"
        placeholder="点击选择缺陷类型" @click="showPickerManageReason1 = true" v-if="isShowManageReasonName" />
      <van-field required readonly class="formstyle" name="picker" :value="ManageReasonName1" label="缺陷类型"
        placeholder="点击选择缺陷类型" v-if="!isShowManageReasonName" />
      <van-popup v-model="showPickerManageReason1" position="bottom">
        <van-picker show-toolbar :columns="columnsManageReason" @confirm="onConfirmManageReason1"
          @cancel="showPickerManageReason1 = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.ManageReasonName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <van-field required readonly class="formstyle" name="picker" :value="ManageReasonName2" label="缺陷类型"
        placeholder="点击选择缺陷类型" @click="showPickerManageReason2 = true" v-if="isShowManageReasonName" />
      <van-popup v-model="showPickerManageReason2" position="bottom">
        <van-picker show-toolbar :columns="columnsManageReason" @confirm="onConfirmManageReason2"
          @cancel="showPickerManageReason2 = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.ManageReasonName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <van-field required readonly class="formstyle" name="picker" :value="ManageReasonName3" label="缺陷类型"
        placeholder="点击选择缺陷类型" @click="showPickerManageReason3 = true" v-if="isShowManageReasonName" />
      <van-popup v-model="showPickerManageReason3" position="bottom">
        <van-picker show-toolbar :columns="columnsManageReason" @confirm="onConfirmManageReason3"
          @cancel="showPickerManageReason3 = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.ManageReasonName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <!-- 增加拍照功能 -->
      <van-field v-if="isShowManageReasonName" :readonly="true" class="formstyle" size="large" name="checkres"
        @click="showCamera(1)" label="点击拍照上传" placeholder="————点击拍照————" right-icon="assets/right.png" />
      <div class="formstyle" v-if="equipRepairVo1.picList !== undefined &&
        equipRepairVo1.picList.length > 0
        ">
        <div style="margin-left: 15px;margin-bottom: 15px;" v-for="(imgUrl, ks) in equipRepairVo1.picList" :key="ks">
          <div class="van-uploader__wrapper" style="float: left">
            <div class="van-uploader__preview">
              <div @click="picShow1(ks)" class="van-image van-uploader__preview-image">
                <img :src="imgUrl" class="van-image__img" />
              </div>
              <div class="van-uploader__preview-delete" @click="delObj1('pic', imgUrl)">
                <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i>
              </div>
            </div>
          </div>
        </div>
      </div>
      <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
        left-icon="description">缺陷信息 - 一般缺陷</NoticeBar>
      <van-field class="formstyle" readonly v-model="form.SamplePlan2AQL" name="抽样计划AQL" label="抽样计划AQL"
        placeholder="输入抽样计划AQL" />
      <van-field class="formstyle" readonly v-model="form.SamplePlan2AC" name="抽样计划AC/RE" label="抽样计划AC/RE"
        placeholder="输入抽样计划AC/RE" />
      <van-field class="formstyle" required v-model="form.SamplePlan2Value" name="异常数量" label="异常数量" placeholder="输入异常数量"
        @input="isShowQProblemNameMethod" />
      <van-field required readonly class="formstyle" name="picker" :value="QProblemName1" label="缺陷类型"
        placeholder="点击选择缺陷类型" @click="showPickerQProblem1 = true" v-if="isShowQProblemName" />
      <van-field required readonly class="formstyle" name="picker" :value="QProblemName1" label="缺陷类型"
        placeholder="点击选择缺陷类型" v-if="!isShowQProblemName" />
      <van-popup v-model="showPickerQProblem1" position="bottom">
        <van-picker show-toolbar :columns="columnsQProblem" @confirm="onConfirmQProblem1"
          @cancel="showPickerQProblem1 = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.QProblemName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <van-field required readonly class="formstyle" name="picker" :value="QProblemName2" label="缺陷类型"
        placeholder="点击选择缺陷类型" @click="showPickerQProblem2 = true" v-if="isShowQProblemName" />
      <van-popup v-model="showPickerQProblem2" position="bottom">
        <van-picker show-toolbar :columns="columnsQProblem" @confirm="onConfirmQProblem2"
          @cancel="showPickerQProblem2 = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.QProblemName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <van-field required readonly class="formstyle" name="picker" :value="QProblemName3" label="缺陷类型"
        placeholder="点击选择缺陷类型" @click="showPickerQProblem3 = true" v-if="isShowQProblemName" />
      <van-popup v-model="showPickerQProblem3" position="bottom">
        <van-picker show-toolbar :columns="columnsQProblem" @confirm="onConfirmQProblem3"
          @cancel="showPickerQProblem3 = false">
          <template #option="option">
            <div style="display: flex; flex-direction: column; align-items: center">
              <div>{{ option.QProblemName }}</div>
            </div>
          </template>
        </van-picker>
      </van-popup>
      <!-- 增加拍照功能 -->
      <van-field v-if="isShowQProblemName" :readonly="true" class="formstyle" size="large" name="checkres"
        @click="showCamera(2)" label="点击拍照上传" placeholder="————点击拍照————" right-icon="assets/right.png" />
      <div class="formstyle" v-if="equipRepairVo2.picList !== undefined &&
        equipRepairVo2.picList.length > 0
        ">
        <div style="margin-left: 15px;margin-bottom: 15px;" v-for="(imgUrl, ks) in equipRepairVo2.picList" :key="ks">
          <div class="van-uploader__wrapper" style="float: left">
            <div class="van-uploader__preview">
              <div @click="picShow2(ks)" class="van-image van-uploader__preview-image">
                <img :src="imgUrl" class="van-image__img" />
              </div>
              <div class="van-uploader__preview-delete" @click="delObj2('pic', imgUrl)">
                <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i>
              </div>
            </div>
          </div>
        </div>
      </div>
      <NoticeBar color="#1989fa" background="#ecf9ff" style="margin-top: 5px; font-size: 15px; font-weight: bold"
        left-icon="description">结果判定</NoticeBar>
      <van-field name="检验结果" class="formstyle" label="检验结果" required>
        <template #input>
          <van-radio-group v-model="valueQualityOk" direction="horizontal" @change="changeQualityOk">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </template>
      </van-field>
      <van-field class="formstyle" v-model="form.Memo" name="需注明的缺陷描述" label="需注明的缺陷描述" placeholder="需注明的缺陷描述"
        type="textarea" rows="4" maxlength="1000" />
      <div style="margin: 16px">
        <van-button color="#138087" round block type="info" native-type="submit" @click="submitsure">提交</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import {
  Col,
  Row,
  Form,
  Cell,
  Icon,
  Field,
  NumberKeyboard,
  Image as VanImage,
  Picker,
  popup,
  SubmitBar,
  Button,
  Loading,
  Overlay,
  Dialog,
  Toast,
  NoticeBar,
  Tag,
  DatetimePicker,
  ImagePreview,
  CellGroup,
  Uploader,
  Cascader,
  Calendar,
  RadioGroup,
  Radio,
  Divider,
  Stepper,
  AddressList,
  Checkbox,
  CheckboxGroup,
} from "vant";

import "vue-easytable/libs/themes-base/index.css";
import { VTable } from "vue-easytable";
import { _httpClient } from "@/libs/apisie";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { getToken, getBaseApiFrefix } from "@/libs/auth";
import Header from "@/components/header.vue";
import { storage } from "@/libs/utils";
import { FastClick } from "fastclick";

Vue.use(Form);
Vue.use(Field);
Vue.use(Overlay);
Vue.use(Loading);
Vue.use(Picker);
Vue.use(popup);
Vue.use(SubmitBar);
Vue.use(VanImage);
Vue.use(DatetimePicker);
Vue.use(Cascader);
Vue.use(Calendar);
Vue.use(Cell);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Divider);
Vue.use(Stepper);
Vue.use(Button);
Vue.use(AddressList);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Col);
Vue.use(Row);

export default {
  name: "qCcheck",
  components: {
    Form,
    Row,
    Col,
    Button,
    Header,
    Form,
    Cell,
    Icon,
    Field,
    NumberKeyboard,
    Dialog,
    Toast,
    NoticeBar,
    Row,
    Tag,
    popup,
    DatetimePicker,
    ImagePreview,
    CellGroup,
    Uploader,
    Col,
    Calendar,
    Cascader,
    Picker,
    RadioGroup,
    Radio,
    Divider,
    Stepper,
    VTable,
    AddressList,
    Checkbox,
    CheckboxGroup,
  },
  data() {
    return {
      resions: [],
      ggg: false,
      duonumber1: "",
      duonumber: "",
      doworkitem: "",
      ddd2: true,
      checked: "",
      ddd: false,
      ddd1: false,
      eee: false,
      van1: true,
      fff: false,
      QProblemName1: "",
      QProblemName2: "",
      QProblemName3: "",
      ManageReasonName1: "",
      ManageReasonName2: "",
      ManageReasonName3: "",
      photoList1: [
        //图片
      ],
      photoList2: [
        //图片
      ],
      equipRepairVo1: {
        eqKey: null,
        equipName: "",
        equipCode: "",
        remark: null,
        picList: [],
        videoList: [],
        audioList: [],
        requestTime: this.getNowTime(),
        requestUser: "",
      },
      equipRepairVo2: {
        eqKey: null,
        equipName: "",
        equipCode: "",
        remark: null,
        picList: [],
        videoList: [],
        audioList: [],
        requestTime: this.getNowTime(),
        requestUser: "",
      },
      query: {
        TimeFrom: ""
      },
      isShowManageReasonName: false,
      isShowQProblemName: false,
      userName: "",
      showPickerUser: false,
      columnsQProblem: [],
      columnsTimeRangeName11: [
        { TimeRangeName: "0:30" },
        { TimeRangeName: "1:30" },
        { TimeRangeName: "2:30" },
        { TimeRangeName: "3:30" },
        { TimeRangeName: "4:30" },
        { TimeRangeName: "5:30" },
        { TimeRangeName: "6:30" },
        { TimeRangeName: "7:30" },
        { TimeRangeName: "8:30" },
        { TimeRangeName: "9:30" },
        { TimeRangeName: "10:30" },
        { TimeRangeName: "11:30" },
        { TimeRangeName: "12:30" },
        { TimeRangeName: "13:30" },
        { TimeRangeName: "14:30" },
        { TimeRangeName: "15:30" },
        { TimeRangeName: "16:30" },
        { TimeRangeName: "17:30" },
        { TimeRangeName: "18:30" },
        { TimeRangeName: "19:30" },
        { TimeRangeName: "20:30" },
        { TimeRangeName: "21:30" },
        { TimeRangeName: "22:30" },
        { TimeRangeName: "23:30" },
      ],
      columnsUser: [
        { userName: "宝洁" },
        { userName: "亨氏" },
        { userName: "蓝月亮" },
        { userName: "利洁时" },
        { userName: "联合利华" },
        { userName: "欧莱雅" },
        { userName: "伊利" },
        { userName: "庄臣" },
        { userName: "资生堂" },
      ],
      columnsCheckedMan: [],
      user: [], //当前登录用户
      minDate: new Date(2023, 1, 1),
      placeholder: "请扫描包装条码",
      form: {
        CheckedMan: "",
        //班组
        valueteamid: "",
        //班次
        pShiftID: "",
        //订单号码
        pOrderID: "",
        //产品代码
        materialid: "",
        //产品名称
        materialname: "",
        //生产日期
        ProductionDate: "",
        //班次开始日期
        planworkdatetime: "",
        //班次
        pShiftID: "",
        //检验类型
        CheckTypeID: "AP03-01",
        //包装条码
        BarCode: "",
        //检验备注
        Memo: "",
        ProductionAmount: "",
        //实际抽样数量
        SampleAmount: "",
        //抽样计划1G
        SamplePlan1G: "",
        //抽样计划1Re
        SamplePlan1Re: "",
        //抽检值1
        SamplePlan1Value: 0,
        //抽样计划2G
        SamplePlan2G: "",
        //抽样计划2AC
        SamplePlan2AC: "",
        //抽样计划2AQL
        SamplePlan2AQL: "",
        //抽检值2
        SamplePlan2Value: 0,
        //生产批次
        BatchID: "",
        //缺陷原因
        QProblemID: "",
        //管理责任
        ManageReasonID: "",
        //生产车间
        WorkshopID: "",
        //检验是否合格
        QualityOk: "",
        //客户名称
        CustomerName: "",
        // A每箱/垛数量
        CountPerBox: "",
        //B本批生产箱数/垛数
        BoxInBatch: 0,
        //C每垛/箱抽检数量
        SamplePerBox: "",
        //D抽检垛/箱数量
        SampleBox: "",
      },
      valueQualityOk: "1",
      plineID: "",
      ManageReasonName: "无异常",
      time: "",
      FactoryID: "",
      valuepShiftName: "",
      CheckTypeName: "",
      CheckTypeNameplus: "",
      QProblemName: "无异常",
      valueteamid: "",
      BeginTime: "",
      WorkPlanDatetimeFrom: "",
      columnsteamId: [],
      showPickerteamid: false,
      showPickerpShiftID: false,
      valueemployid: "",
      columnsshift: [],
      columnsType: [],
      columnsManageReason: [
        // { ManageReasonID: "0", ManageReasonName: "无异常" },
      ],
      columnsQProblem: [
        // { QProblemID: "0", QProblemName: "无异常" }
      ],

      showPickeremployid: false,
      showPickerdatetime: false,
      showPickerType: false,
      showPickerManageReason1: false,
      showPickerManageReason2: false,
      showPickerManageReason3: false,
      showPickerQProblem1: false,
      showPickerQProblem2: false,
      showPickerQProblem3: false,
      showPickerCheckedMan: false,
      BarCodeLsit: [],
      countNum: 0,
      isMustShowScanner2: false,
      QProblemIDList: ["无", "无", "无"],
      ManageReasonIDList: ["无", "无", "无"],
      toData: {},

      valueTimeRange: "",
      valueTimeRange11: "",
      valueTimeRange22: "",
      columnsTimeRangeName: [],
      columnsTimeRangeNameplus: [],
      isShowTimeRangeName: false,
      showPickerTimeRangeName: false,
      showPickerTimeRangeName11: false,
      ApprenStrictItem: "",

    };
  },
  created: function () {
    this.user = JSON.parse(storage.get("user"));
    this.user.userId = this.user.userName;
    api.requestPermission(
      {
        list: ["camera", "microphone", "storage"],
      },
      function (ret, err) { }
    );

    // try {
    //   var manageStorage = api.require('manageStorage');
    //   manageStorage.requestAllFilePermission({
    //   }, function (ret) {
    //     // api.alert({
    //     //   msg: JSON.stringify(ret)
    //     // })
    //   });
    // } catch {

    // }
    
    this.showScanner();
    this.getFactoryID();
    this.getTimeRange();
    this.form.planworkdatetime = new Date().toLocaleString();
    this.form.ProductionDate = this.getNowTime();

    this.ManageReasonName1 = "无异常";
    this.form.ManageReasonID = "0";
    this.ManageReasonIDList[0] = this.form.ManageReasonID;

    this.QProblemName1 = "无异常";
    this.form.QProblemID = "0";
    this.QProblemIDList[0] = this.form.QProblemID;

    this.checked = "1";

  },
  mounted() {
    //获取班组信息
    this.getteam();
    //获取班次信息
    this.getshift();
    //获取检验类型
    this.getCheckType();
    //管理责任数据
    this.getManageReasonID();
    this.getQualityProblems();
    this.getCheckedMan();

  },

  methods: {
    async seejiayan() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/AddStrictManage/GetOnActiveStrict?PLineID=" + _this.plineID
        );
        if (res.HttpCode === "200") {
          //alert(res.Data);
          if (res.Data.length > 0) {
            api.openWin({
              name: "quality-jiayanitem",
              url: "./quality-jiayanitem.html",
              pageParam: {
                item: _this.plineID
              },
              reload: true
            });
          }
          else {
            Toast.fail("生产线" + _this.plineID + "没有活动加严，无法显示");
          }
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    picShow1(pIndex) {
      ImagePreview({
        images: this.equipRepairVo1.picList || [],
        showIndicators: true,
        startPosition: pIndex || 0,
        showIndex: false,
      });
    },
    picShow2(pIndex) {
      ImagePreview({
        images: this.equipRepairVo2.picList || [],
        showIndicators: true,
        startPosition: pIndex || 0,
        showIndex: false,
      });
    },
    showCamera(index) {
      let that = this;
      //alert("手机系统"+api.deviceName.toLowerCase());
      //判断设备系统类型
      if (api.systemType == "ios") {
        that.iosCamera(index);
      } else {
        if (api.deviceName.toLowerCase() == "vivo") {
          that.vivoCamera(index);
        } else if (api.deviceName.toLowerCase() == "oppo") {
          that.oppoReno2Camera(index);
        } else if (api.deviceName.toLowerCase() == "oneplus") {
          that.oppoReno2Camera(index);
        } else if (api.deviceName.toLowerCase() == "honor") {
          that.vivoCamera(index);
        } else if (api.deviceName.toLowerCase() == "xiaomi") {
          that.vivoCamera(index);
        } else if (api.deviceName.toLowerCase() == "meizu") {
          that.vivoCamera(index);
        } else if (api.deviceName.toLowerCase() == "realme") {
          that.vivoCamera(index);
        } else if (api.deviceName.toLowerCase() == "huawei") {
          that.vivoCamera(index);
          // that.otherCamera(index);
        } else if (api.deviceName.toLowerCase() == "ptac") {
          that.vivoCamera(index);
        } else {
          that.vivoCamera(index);
          // that.otherCamera(index);
        }
        // var phoneInfo = api.require('phoneInfo')
        // phoneInfo.getBaseInfo(function(ret, err) {
        //   if (ret.status) {
        //     if (ret.brand == 'vivo') {
        //       // that.vivoCamera()
        //       that.iosCamera()
        //     } else if (ret.brand == 'oppo') {
        //       that.oppoReno2Camera()
        //     } else {
        //       that.otherCamera()
        //     }
        //   } else {
        //     api.alert({ msg: err.msg })
        //   }
        // })
      }
    },

    vivoCamera(index) {
      let that = this;
      var FNPhotograph = api.require("FNPhotograph");
      FNPhotograph.open(
        {
          album: false,
          quality: "high",
          isShowAlbum: false,
          // useAdvanceFeature: true,
          // pictureSize: '2075x1080',
          // previewSize: '2075x1080',
        },
        function (ret) {
          if (ret && ret.eventType == "takePhoto") {
            let imgSrc = ret.imagePath;
            if (imgSrc && imgSrc != "") {
              FNPhotograph.close();
              that.imageFilter(imgSrc,index);
            }
          }
        }
      );
    },
    xiaomiCamera(index) {
      let that = this;
      var cameraTool = api.require("cameraTool");
      cameraTool.openCamera(function (ret, err) {
        let imgPath = ret.imgPath;
        if (imgPath && imgPath != "") {
          that.imageFilter(imgPath, index);
        }
      });
    },
    oppoReno2Camera(index) {
      let _this = this;
      api.getPicture(
        {
          sourceType: "camera",
          encodingType: "jpg",
          mediaValue: "pic",
          allowEdit: false,
          destinationType: "url",
          quality: 50,
        },
        function (ret, err) {
          // 获取拍照数据并处理
          if (ret) {
            let imgSrc = ret.data;
            if (imgSrc && imgSrc != "") {
              _this.imageFilter(imgSrc, index);
            }
          }
        }
      );
    },

    otherCamera(index) {
      let that = this;
      // var cameraTool = api.require('cameraTool')
      // cameraTool.openCamera(function(ret, err) {
      //   let imgPath = ret.imgPath
      //   if (imgPath && imgPath != '') {
      //     that.imageFilter(imgPath)
      //   }
      // })
      var module = api.require("easyCamera");
      var param = {
        typeString: "image", // 或者'video-20'
      };
      var resultCallback = function (ret, err) {
        var msg = ret.msg;
        if (msg && msg != "") {
          that.imageFilter(msg, index);
        }
      };
      module.openCamera(param, resultCallback);
    },
    otherCameraPlus(index) {
      let that = this;
      var ox = api.require("oxWxRecorder");
      ox.getPermission(function (ret) {
        var code = ret.code;
        if (code == 1) {
          ox.open(
            {
              fixedOn: api.frameName,
              rect: { x: 0, y: 0, w: w, h: h },
              fixed: true,
              type: 2, //0拍照录像 1 录像 2 拍照
            },
            function (ret1) {
              var code1 = ret1.code;
              if (code1 == 0) {
                //关闭事件
              } else if (code1 == 2) {
                //返回图片路径path
                that.imageFilter(ret1.path, index);
              } else if (code1 == -1) {
                //错误信息
                alert(ret1.text);
              }
            }
          );
        }
      });
    },
    iosCamera(index) {
      let that = this;
      let zySmallVideo = api.require("zySmallVideo");
      zySmallVideo.openNew(
        {
          rect: {
            //模块 附于一个frame之上
            x: 0,
            y: 0,
            w: api.frameWidth,
            h: api.frameHeight,
          },
          fixedOn: api.frameName,
          fixed: true,
          videoInfo: {
            setOutputFormat: 2, //录制格式 默认2 mp4  0（DEFAULT） 1（THREE_GPP） 2（MPEG_4默认） 3（RAW_AMR） 4（AMR_WB） 5（AAC_ADIF） 6（AAC_ADTS） 7（OUTPUT_FORMAT_RTP_AVP） 8（OUTPUT_FORMAT_MPEG2TS） 9（WEBM）
            setVideoEncoder: 2, //编码格式 默认2 h264 0（DEFAULT） 1（H263） 2（H264默认） 3（MPEG_4_SP） 4（VP8） 5（HEVC）
            setAudioEncoder: 3, //音频格式应该是 默认3 aac  0（DEFAULT） 1（AMR_NB） 2（AMR_WB） 3（AAC默认） 4（HE_AAC） 5（AAC_ELD） 6（VORBIS）
          },
          MaxRecordTime: 60, //最大录制时间 单位秒 默认10
          MinRecordTime: 5, //最短录制时间  单位s
          MinTimeText: "时间不能小于5秒，不能大于60秒", //最短时间提示词
          setFeatures: 1001, //设置拍照和录像   1001只拍照   1002只录像   1003两者都可以  默认1003
          setTip: "", //设置按钮上的提示词   长按拍摄等 默认空
          setBackIcon: "", //自定义返回图标 默认向下键头  支持widget  fs 等路径图片
          setBackShow: 1, //设置返回图标是否显示 1是 0否  默认1
          setCameraIcon: "", //自定义切换摄像头图标  支持widget  fs 等路径图片
          setCameraShow: 1, //右上角切换摄像头是否显示 1是 0否 默认1
          cameraInfo: {
            //摄像头 设置样式
            fit_xy: false, //图片是否拉伸占满宽高  默认false
            margin_l: 0, //距左 默认都是0
            margin_r: 35, //距右
            margin_t: 65, //距上
            margin_b: 0, //距下
          },
          foucsInfo: {
            //点击的对焦框 样式
            color: "#cd0000", //线条颜色 默认16AE16
            width: 4, //线条宽度 默认4
          },
          recordInfo: {
            progress_color: "#cd0000", //进度条颜色 默认16AE16
            outside_color: "#DCDCDC", //外圆背景色 默认DCDCDC
            inside_color: "#FFFFFF", //内圆背景色 默认FFFFFF
          },
          confirmInfo: {
            //确认框参数
            fit_xy: false, //图片是否拉伸占满宽高  默认false
            img: "", //设置自定义图片
          },
          cancelInfo: {
            //取消框参数
            fit_xy: false, //图片是否拉伸占满宽高  默认false
            img: "", //设置自定义图片
          },
        },
        function (ret, err) {
          if (ret.status) {
            if (ret.type == "captureSuccess") {
              that.imageFilter(ret.result, index);
            }
          }
        }
      );
    },

    //图片压缩
    imageFilter(imgPath, index) {
      let that = this;
      var imageFilter = api.require("imageFilter");
      var imageCachePath = api.cacheDir; //cache://协议对应的真实目录，字符串类型
      imageFilter.compress(
        {
          img: imgPath,
          quality: 0.5,
          size: "800X600",
          save: {
            album: false,
            imgPath: imageCachePath + "/",
            imgName: "cs.jpg",
          },
        },
        function (ret, err) {
          let imgUrl = imageCachePath + "/cs.jpg";
          that.getFileName("pic", imgUrl, index);
          //文件删除
          var fs = api.require("fs");
          fs.remove(
            {
              path: imgPath,
            },
            function (ret, err) {
              if (ret.status) {
              } else {
              }
            }
          );
        }
      );
    },
    //获取文件名称
    async getFileName(fType, fUrl, index) {
      let type = "jpg";
      if (fType === "audio") {
        type = "amr";
      } else if (fType === "video") {
        type = "mp4";
      } else if (fType === "pic") {
        type = "jpg";
      } else if (fType === "audio2") {
        type = "aac";
      }
      let res = await _httpClient.get(
        _httpClientApi.getApiPrefix() + "/minio/oss/getFileName?fileType=" + type
      );
      if (res.code === 200) {
        //上传文件
        this.putObj(fType, fUrl, res.fileName, index);
      }
    },

    //定时器
    timeCycle(fType, fileName, index) {
      let that = this;
      let cycleNum = 0;
      that.uploadSuccess = false;
      let intervald = setInterval(() => {
        if (
          that &&
          !that._isDestroyed &&
          cycleNum < _httpClient.getUploadCycle() &&
          !that.uploadSuccess
        ) {
          setTimeout(() => {
            if (that && !that._isDestroyed) {
              that.queryFileUpload(fType, fileName, index);
              cycleNum++;
            }
          }, 0);
        } else {
          //清除定时器
          clearInterval(intervald);
          that.uploadSuccess = true;
          Toast.clear();
          if (cycleNum == _httpClient.getUploadCycle()) {
            alert("上传超时，请重试");
          }
        }
      }, 2000);
    },

    //查询文件是否上传成功
    async queryFileUpload(fType, fileName, index) {
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "校验保存中...",
      });
      let that = this;
      let res = await _httpClient.get(
        _httpClientApi.getApiPrefix() + "/minio/oss/" + fileName
      );
      if (res.code === 200) {
        let urls = res.objectURL.split("?");
        if (urls.length > 0) {
          if (fType === "audio") {
            that.equipRepairVo.audioList.push(urls[0]);

            let newList2 = []
            that.equipRepairVo.audioList.forEach((item) => {
              // 空数组newList2 不包含item为false ,取反为true 执行数组添加操作
              // 如果数组包含了 item为true 取反为false 不执行数组添加操作
              if (!newList2.includes(item)) {
                newList2.push(item)
              }
            })

            that.equipRepairVo.audioList = newList2;
            // that.equipRepairVo.audioList = that.equipRepairVo.audioList.filter(function (item, index) {
            //   return arr.indexOf(item) === index;  // 因为indexOf 只能查找到第一个
            // });
          } else if (fType === "video") {
            that.equipRepairVo.videoList.push(urls[0]);

            let newList2 = []
            that.equipRepairVo.videoList.forEach((item) => {
              // 空数组newList2 不包含item为false ,取反为true 执行数组添加操作
              // 如果数组包含了 item为true 取反为false 不执行数组添加操作
              if (!newList2.includes(item)) {
                newList2.push(item)
              }
            })
            that.equipRepairVo.videoList = newList2;

            // that.equipRepairVo.videoList = that.equipRepairVo.videoList.filter(function (item, index) {
            //   return arr.indexOf(item) === index;  // 因为indexOf 只能查找到第一个
            // });
          } else if (fType === "pic") {
            if (index == 1) {
              that.equipRepairVo1.picList.push(urls[0]);

              let newList2 = []
              that.equipRepairVo1.picList.forEach((item) => {

                if (!newList2.includes(item)) {
                  newList2.push(item)
                }
              })

              that.equipRepairVo1.picList = newList2;
            }
            else {
              that.equipRepairVo2.picList.push(urls[0]);

              let newList2 = []
              that.equipRepairVo2.picList.forEach((item) => {
                if (!newList2.includes(item)) {
                  newList2.push(item)
                }
              })

              that.equipRepairVo2.picList = newList2;
            }
          } else if (fType === "audio2") {
            that.equipRepairVo.audioList.push(urls[0]);

            let newList2 = []
            that.equipRepairVo.audioList.forEach((item) => {
              // 空数组newList2 不包含item为false ,取反为true 执行数组添加操作
              // 如果数组包含了 item为true 取反为false 不执行数组添加操作
              if (!newList2.includes(item)) {
                newList2.push(item)
              }
            })

            that.equipRepairVo.audioList = newList2;
            // that.equipRepairVo.audioList = that.equipRepairVo.audioList.filter(function (item, index) {
            //   return arr.indexOf(item) === index;  // 因为indexOf 只能查找到第一个
            // });
          }



          Toast("上传成功");
        }
        Toast.clear();
        that.uploadSuccess = true;
      }
    },

    //文件上传
    putObj(fType, fUrl, fileName, index) {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "上传中...0%",
      });
      api.ajax(
        {
          url:
            _httpClientApi.getApiPrefix() +
            "/minio/oss/appPutObject?fileName=" +
            fileName,
          //  url: 'http://192.168.2.102:8083' + '/minio/oss/putObject',
          method: "post",
          headers: {
            Authorization: "Bearer " + getToken(),
          },
          report: true,
          data: {
            files: {
              file: fUrl,
            },
          },
        },
        function (ret, err) {
          if (ret) {
            Toast.loading({
              mask: true,
              forbidClick: true,
              duration: 0,
              message: "上传进度...\n" + ret.progress + "%",
            });
            if (ret.body.code === 200) {
              if (api.systemType == "ios") {
                _this.timeCycle(fType, fileName, index);
                //文件删除
                var fs = api.require("fs");
                fs.remove(
                  {
                    path: fUrl,
                  },
                  function (ret, err) {
                    if (ret.status) {
                    } else {
                    }
                  }
                );
              }
            } else if (ret.progress == 100) {
              if (api.systemType != "ios") {
                _this.timeCycle(fType, fileName, index);
                //文件删除
                var fs = api.require("fs");
                fs.remove(
                  {
                    path: fUrl,
                  },
                  function (ret, err) {
                    if (ret.status) {
                    } else {
                    }
                  }
                );
              }
            }
          } else {
            Toast.clear();
          }
        }
      );
    },
    async delObj1(fType, fUrl) {
      this.commitLoading = false;
      let fname = "";
      try {
        if (fUrl != undefined && fUrl != "" && fUrl != null) {
          fname = fUrl.substring(fUrl.lastIndexOf("/") + 1);
        }
        let res = await _httpClient.delete(
          _httpClientApi.getApiPrefix() + "/minio/oss/" + fname
        );
        if (res.code === 200) {
          let flist = [];
          if (fType === "audio") {
            flist = this.equipRepairVo1.audioList;
          } else if (fType === "video") {
            flist = this.equipRepairVo1.videoList;
          } else if (fType === "pic") {
            flist = this.equipRepairVo1.picList;
          }
          if (flist.length > 0) {
            for (var i = 0; i < flist.length; i++) {
              if (flist[i] == fUrl) {
                flist.splice(i, 1);
              }
            }
          }
          Toast.success(res.msg);
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    async delObj2(fType, fUrl) {
      this.commitLoading = false;
      let fname = "";
      try {
        if (fUrl != undefined && fUrl != "" && fUrl != null) {
          fname = fUrl.substring(fUrl.lastIndexOf("/") + 1);
        }
        let res = await _httpClient.delete(
          _httpClientApi.getApiPrefix() + "/minio/oss/" + fname
        );
        if (res.code === 200) {
          let flist = [];
          if (fType === "audio") {
            flist = this.equipRepairVo2.audioList;
          } else if (fType === "video") {
            flist = this.equipRepairVo2.videoList;
          } else if (fType === "pic") {
            flist = this.equipRepairVo2.picList;
          }
          if (flist.length > 0) {
            for (var i = 0; i < flist.length; i++) {
              if (flist[i] == fUrl) {
                flist.splice(i, 1);
              }
            }
          }
          Toast.success(res.msg);
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    isShowManageReasonNameMethod() {
      var denominator = this.form.SamplePlan2AC.split("/");
      if (this.form.SamplePlan1Value > 0) {
        this.isShowManageReasonName = true;
        this.ManageReasonName1 = "";
        this.ManageReasonName2 = "";
        this.ManageReasonName3 = "";
        this.form.ManageReasonID = "";
        this.ManageReasonIDList[0] = "无";
        this.ManageReasonIDList[1] = "无";
        this.ManageReasonIDList[2] = "无";
        this.valueQualityOk = "0";
        this.form.QualityOk = false;
      } else {
        this.isShowManageReasonName = false;
        this.ManageReasonName1 = "无异常";
        this.form.ManageReasonID = "0";
        this.ManageReasonIDList[0] = this.form.ManageReasonID;
        if (
          parseInt(this.form.SamplePlan1Value) == 0 &&
          parseInt(this.form.SamplePlan2Value) < parseInt(denominator[1])
        ) {
          this.valueQualityOk = "1";
          this.form.QualityOk = true;
        }
      }
    },
    isShowQProblemNameMethod() {
      // alert(this.form.SamplePlan1Value)
      var denominator = this.form.SamplePlan2AC.split("/");
      // if (this.form.SamplePlan1Value > 0) {
      //   // alert("cc")
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
      // else {
      if (parseInt(this.form.SamplePlan2Value) >= parseInt(denominator[1])) {
        // alert('1')
        this.isShowQProblemName = true;
        this.QProblemName1 = "";
        this.QProblemName2 = "";
        this.QProblemName3 = "";
        this.form.QProblemID = "";
        this.QProblemIDList[0] = "无";
        this.QProblemIDList[1] = "无";
        this.QProblemIDList[2] = "无";
        this.valueQualityOk = "0";
        this.form.QualityOk = false;
      }
      else if (parseInt(this.form.SamplePlan2Value) > 0 && parseInt(this.form.SamplePlan2Value) < parseInt(denominator[1])) {
        // alert('2')
        this.isShowQProblemName = true;
        this.QProblemName1 = "";
        this.QProblemName2 = "";
        this.QProblemName3 = "";
        this.form.QProblemID = "";
        this.QProblemIDList[0] = "无";
        this.QProblemIDList[1] = "无";
        this.QProblemIDList[2] = "无";
        if (this.form.SamplePlan1Value > 0) {
          this.valueQualityOk = "0";
          this.form.QualityOk = false;
        } else {
          this.valueQualityOk = "1";
          this.form.QualityOk = true;
        }

      }
      else {
        // alert("3")
        this.isShowQProblemName = false;
        this.QProblemName1 = "无异常";
        this.form.QProblemID = "0";
        this.QProblemIDList[0] = this.form.QProblemID;
        if (
          parseInt(this.form.SamplePlan1Value) == 0 &&
          parseInt(this.form.SamplePlan2Value) < parseInt(denominator[1])
        ) {
          if (this.form.SamplePlan1Value > 0) {
            this.valueQualityOk = "0";
            this.form.QualityOk = false;
          } else {
            this.valueQualityOk = "1";
            this.form.QualityOk = true;
          }
        }
      }
    },
    onConfirmUser(value, index) {
      this.form.CustomerName = this.columnsUser[index].userName;
      this.userName = this.columnsUser[index].userName;
      this.showPickerUser = false;
    },
    setProductionAmount() {
      this.form.ProductionAmount = this.form.CountPerBox * this.form.BoxInBatch;

      if (this.valueTimeRange == "不选") {
        if (
          this.form.CheckTypeID == "CT03" ||
          this.form.CheckTypeID == "CT04" ||
          this.form.CheckTypeID == "CT05"
        ) {
          this.getDataByMaterial(1);
        } else {
          this.getDataByMaterial(0);
        }
      }
      else {
        //alert(this.form.CheckTypeID);
        if (this.form.CheckTypeID == "AP01-01" || this.form.CheckTypeID == "AP02-01" || this.form.CheckTypeID == "AP03-01") {
          this.getDataByMaterial(4);
        }
        else if (this.form.CheckTypeID == "AP01-02" || this.form.CheckTypeID == "AP02-02" || this.form.CheckTypeID == "AP03-02") {
          this.getDataByMaterial(0);
        }
        else if (this.form.CheckTypeID == "AP01-03" || this.form.CheckTypeID == "AP02-03" || this.form.CheckTypeID == "AP03-03") {
          this.getDataByMaterial(2);
        }
        else if (this.form.CheckTypeID == "AP01-04" || this.form.CheckTypeID == "AP02-04" || this.form.CheckTypeID == "AP03-04") {
          this.getDataByMaterial(3);
        }
      }

      if (this.form.BoxInBatch <= 3) {
        this.form.SampleBox = this.form.BoxInBatch;
      } else if (this.form.BoxInBatch >= 4 && this.form.BoxInBatch <= 9) {
        this.form.SampleBox = 3;
      } else if (this.form.BoxInBatch >= 10) {
        this.form.SampleBox = Math.ceil(Math.sqrt(this.form.BoxInBatch) + 1);
      }

      this.setNotice();
    },
    //设置包装数
    setNotice() {
      if (this.form.SamplePerBox != "") {
        if (this.form.SamplePerBox * this.form.SampleBox < this.form.PlanBox) {
          Toast.fail("实际抽样数量要大于计划抽样数量!");
        }
      }
      if (this.form.SampleBox == "" || null == this.form.SampleBox) {
        this.placeholder = "点击扫描包装条码";
        return;
      }
      this.countNum = this.form.SampleBox;
      this.placeholder = "未扫描包装条码" + this.countNum + "个";
      this.BarCodeLsit = [];
      this.setonConfirmtype();
    },
    setNotice4() {
      this.form.SamplePerBox = this.form.CountPerBox1;
      this.form.SampleBox = this.form.BoxInBatch1;
      try {
        this.form.PlanBox = (Number(this.form.SampleBox) * Number(this.form.SamplePerBox)).toString();
      } catch {
        this.form.PlanBox = "";
      }
      this.countNum = this.form.SampleBox;
      this.placeholder = "未扫描包装条码" + this.countNum + "个";
      this.BarCodeLsit = [];
      this.setonConfirmtype();
    },
    setNotice3() {
      //alert(3);
      this.form.SamplePerBox = this.form.CountPerBox;
      this.form.SampleBox = this.duonumber1;
      try {
        this.form.PlanBox = (Number(this.form.SampleBox) * Number(this.form.SamplePerBox)).toString();
      } catch {
        this.form.PlanBox = "";
      }
      this.countNum = this.duonumber1;
      this.placeholder = "未扫描包装条码" + this.duonumber1 + "个";
      this.BarCodeLsit = [];
      this.setonConfirmtype();
    },
    setNotice1() {
      //alert(1);
      this.form.SampleBox = this.duonumber;
      try {
        this.form.PlanBox = (Number(this.form.SampleBox) * Number(this.form.SamplePerBox)).toString();
      } catch {
        this.form.PlanBox = "";
      }
      // this.countNum = this.duonumber;
      // this.placeholder = "未扫描包装条码" + this.duonumber + "个";
      // this.BarCodeLsit = [];
      // this.setonConfirmtype();
    },
    setNotice2() {
      this.form.SamplePerBox = (Number(this.form.CountPerBox) / Number(this.form.ProductionAmount1)).toString();
      try {
        this.form.PlanBox = (Number(this.form.SampleBox) * Number(this.form.SamplePerBox)).toString();
      } catch {
        this.form.PlanBox = "";
      }
      // this.countNum = this.form.SamplePerBox;
      // this.placeholder = "未扫描包装条码" + this.countNum + "个";
      // this.BarCodeLsit = [];
      // this.setonConfirmtype();
    },
    //记录包装条码
    addBarCode(BarCode) {
      if (this.countNum > 0) {
        this.BarCodeLsit.forEach(function (element) {
          if (BarCode == element) {
            Toast.fail("重复，请重新扫描！");
            this.countNum = this.countNum + 1;
            return;
          }
        });
        this.BarCodeLsit.push(BarCode);
        this.countNum = this.countNum - 1;
        this.placeholder = "未扫描包装条码" + this.countNum + "个";
      }
    },
    //扫描包装条码
    showScanner2() {
      if (this.form.SampleBox == null || this.form.SampleBox == "") {
        alert("请先填写抽样箱/垛数量");
        return;
      }
      let _this = this;
      if (
        api.deviceName.toLowerCase() == "huawei" ||
        api.deviceName.toLowerCase() == "honor"
      ) {
        var zyHmsScan = api.require('zyHmsScan');
        var param = {
          //returnAll:true
        };
        zyHmsScan.openDefaultView(param, function (ret) {
          _this.addBarCode(ret.result);
          //api.alert({ msg: JSON.stringify(ret) });
        });

        // var QRScan = api.require("QRScan");
        // QRScan.customizedScanner(
        //   {
        //     rect: {
        //       x: 0, //（可选项）数字类型；模块左上角的 x 坐标（相对于所属的 Window 或 Frame）；默认：0
        //       y: 0, //（可选项）数字类型；模块左上角的 y 坐标（相对于所属的 Window 或 Frame）；默认：0
        //       w: 320, //（可选项）数字类型；模块的宽度；支持设置'auto'；默认：所属的 Window 或 Frame 的宽度
        //       h: 480, //（可选项）数字类型；模块的高度；支持设置'auto'；默认：所属的 Window 或 Frame 的高度
        //     },
        //     rectOfInterest: {
        //       x: 64, //（可选项）数字类型；扫码识别区域左上角的 x 坐标（相对于扫码区rect）；默认：0
        //       y: 65, //（可选项）数字类型；扫码识别区域左上角的 y 坐标（相对于扫码区rect）；默认：0
        //       w: 250, //（可选项）数字类型；扫码识别区域的宽度；默认：扫码区rect的宽度
        //       h: 250, //（可选项）数字类型；扫码识别区域的高度；默认：扫码区rect的高度
        //     },
        //     //tipString:'放入框内扫码',
        //     maskColor: "rgba(0,0,0,0.5)",
        //     scanLine: {
        //       color: "#00FF00",
        //       thickness: 2,
        //     },
        //     marginB: 30,
        //     formatType: "ALL",
        //   },
        //   function (ret) {
        //     if (ret) {
        //       _this.addBarCode(ret.result);
        //     }
        //   }
        // );
        //QRScan.closeCustomizedScanner();
      } else {
        var FNScanner = this.$ac.require("FNScanner");
        FNScanner.openScanner(
          {
            autorotation: true,
          },
          function (ret, err) {
            if (ret) {
              if (ret.eventType == "success" && ret.content != "") {
                _this.addBarCode(ret.content);
              }
            } else {
              //alert(JSON.stringify(err));
            }
          }
        );
      }
    },
    changeQualityOk() {
      //如果合格 隐藏页面 直接提交
      if (this.valueQualityOk == "1") {
        this.form.QualityOk = true;
      } else {
        //若不合格 填写抽检表单
        this.form.QualityOk = false;
      }
    },
    changeQC() {
      //如果合格 隐藏页面 直接提交
      if (this.checked == "1") {
        this.ddd2 = true;
      } else {
        //若不合格 填写抽检表单
        this.ddd2 = false;
      }
    },
    //获取工厂信息
    async getFactoryID() {
      let _this = this;
      try {
        let res = await _httpClientApi.get(
          _httpClientApi.getApiPrefix() +
          "/system/ConvertFactoryID/getList/" +
          _this.user.site
        );
        if (res.code === 200) {
          _this.FactoryID = res.data.sapfactoryid;
        } else if (res.code === 403) {
          Toast.fail("没有权限，请联系管理员授权");
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //打开扫描
    showScanner() {

      //alert(api.deviceName.toLowerCase());
      var _this = this;
      if (
        api.deviceName.toLowerCase() == "huawei" ||
        api.deviceName.toLowerCase() == "honor"
      ) {
        var zyHmsScan = api.require('zyHmsScan');
        var param = {
          //returnAll:true
        };
        zyHmsScan.openDefaultView(param, function (ret) {
          //_this.addBarCode(ret.result);
          _this.getcurrentorder(ret.result);
          //api.alert({ msg: JSON.stringify(ret) });
        });


        //   var QRScan = api.require("QRScan");
        // QRScan.customizedScanner(
        //   {
        //     rect: {
        //       x: 15, //（可选项）数字类型；模块左上角的 x 坐标（相对于所属的 Window 或 Frame）；默认：0
        //       y: 0, //（可选项）数字类型；模块左上角的 y 坐标（相对于所属的 Window 或 Frame）；默认：0
        //       w: 320, //（可选项）数字类型；模块的宽度；支持设置'auto'；默认：所属的 Window 或 Frame 的宽度
        //       h: 480, //（可选项）数字类型；模块的高度；支持设置'auto'；默认：所属的 Window 或 Frame 的高度
        //     },
        //     rectOfInterest: {
        //       x: 64, //（可选项）数字类型；扫码识别区域左上角的 x 坐标（相对于扫码区rect）；默认：0
        //       y: 65, //（可选项）数字类型；扫码识别区域左上角的 y 坐标（相对于扫码区rect）；默认：0
        //       w: 250, //（可选项）数字类型；扫码识别区域的宽度；默认：扫码区rect的宽度
        //       h: 250, //（可选项）数字类型；扫码识别区域的高度；默认：扫码区rect的高度
        //     },
        //     //tipString:'放入框内扫码',
        //     maskColor: "rgba(0,0,0,0.5)",
        //     scanLine: {
        //       color: "#00FF00",
        //       thickness: 2,
        //     },
        //     marginB: 30,
        //     formatType: "ALL",
        //   },
        //   function (ret) {
        //     if (ret) {
        //       _this.queryTask({
        //         body: {
        //           equipCode: ret.result,
        //           siteKey: _this.user.site,
        //           eqStatus: _this.params.eqStatus,
        //           taskType: _this.params.mnType,
        //         },
        //       });
        //     }
        //   }
        // );
        // QRScan.closeCustomizedScanner();

      }
      else {
        var FNScanner = _this.$ac.require("FNScanner");
        FNScanner.openScanner(
          {
            autorotation: true,
          },
          function (ret, err) {
            if (ret) {
              if (ret.eventType == "success" && ret.content != "") {
                _this.getcurrentorder(ret.content);
              } else if (ret.eventType == "cancel") {
                _this.$ac.closeWin();
              }
            } else {
              //alert(JSON.stringify(err));
              _this.$ac.closeWin();
            }
          }
        );
      }
    },
    //获取⽣产线正在⽣产订单
    async getcurrentorder(machineID) {

      var _this = this;
      _this.plineID = machineID;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/MachineCurrentPOrder/GetCurrentOrder?MachineID=" +
          machineID
        );

        // alert(JSON.stringify(res))
        if (res.HttpCode === "200" && res.Total > 0) {
          //Toast.clear();
          _this.form.pOrderID = res.Data[0].POrderID;
          _this.form.materialid = res.Data[0].MaterailID;
          _this.form.materialname = res.Data[0].MaterailName;
          if (_this.form.materialid.substr(0, 1) === "5") {
            _this.isMustShowScanner2 = true;
          } else {
            _this.isMustShowScanner2 = false;
          }
          //_this.form.CustomerName = "测试";
          //_this.FactoryID = res.Data[0].FactoryID;
          this.getWorkshopIDandSampleData(machineID, res.Data[0].MaterailID);

          let res1 = await _httpClient.get(
            _httpClient.getApiPrefix() +
            "/ZBC_DHJBXX/GetBatchList?POrderID=" +
            _this.form.pOrderID
          );
          if (res1.HttpCode === "200" && res1.Total > 0) {
            Toast.clear();
            // _this.form.BatchID = res1.Data[0].BSKTD;
            _this.form.CountPerBox = res1.Data[0].MENGE;
            _this.form.CountPerBox1 = res1.Data[0].MENGE;
            //this.getWorkshopIDandSampleData(machineID, res.Data[0].MaterailID);
          } else {
            Toast.clear();
            _this.form.BatchID = "";
            _this.form.CountPerBox = "";
            _this.form.CountPerBox1 = "";
          }

          let res2 = await _httpClient.get(
            _httpClient.getApiPrefix() +
            "/AddStrictManage/GetOnActiveStrict?PLineID=" +
            _this.plineID
          );

          // alert(JSON.stringify(res2))
          if (res2.HttpCode === "200" && res2.Total > 0) {
            Toast.clear();
            //alert(JSON.stringify(res2));
            _this.ApprenStrictItem = res2.Data[0].ApprenStrictItem;
            if (res2.Data[0].ApprenType == "AP01") {
              _this.valueTimeRange = "0.5h";
              _this.eee = true;
              _this.ddd1 = true;
            }
            else if (res2.Data[0].ApprenType == "AP02") {
              _this.valueTimeRange = "1h";
              _this.eee = true;
              _this.ddd1 = true;
            }
            else if (res2.Data[0].ApprenType == "AP03") {
              _this.valueTimeRange = "2h";
              _this.eee = true;
              _this.ddd1 = true;
            }
            else {
              _this.valueTimeRange = "2h";
              _this.eee = true;
              _this.ddd1 = true;
            }

            this.doworkitem = res2.Data[0].ApprenStrictItem;
            var ApprenStrictItemstr = res2.Data[0].ApprenStrictItem.split("-");
            //加严类型1
            //alert(JSON.stringify(ApprenStrictItemstr))
            if (ApprenStrictItemstr[1] == "01") {

              _this.CheckTypeNameplus = "正常抽样计划";
              _this.fff = false;

            }
            //加严类型2
            else if (ApprenStrictItemstr[1] == "02") {
              // if (res2.Data[0].ApprenType == "AP03") {
              //   _this.CheckTypeNameplus = "每垛取一箱或一层，每箱/层全检";
              //   _this.form.SamplePlan2AC = "1/2";
              //   _this.fff = true;
              //   _this.$forceUpdate();
              // }
              // else {
              _this.CheckTypeNameplus = "增加每箱检测数量";
              _this.fff = false;
              // }
            }
            //加严类型3
            else if (ApprenStrictItemstr[1] == "03") {
              //alert(res2.Data[0].ApprenType);
              // if (res2.Data[0].ApprenType == "AP03") {
              //   //alert(1);
              //   _this.CheckTypeNameplus = "全检";
              //   _this.form.SamplePlan2AC = "0/1";
              //   _this.fff = false;
              //   _this.ggg =true;
              // }else {
              //alert(2);
              _this.CheckTypeNameplus = "每垛取一箱或一层，每箱/层全检";
              _this.form.SamplePlan2AC = "1/2";
              _this.fff = true;
              _this.$forceUpdate();
              // }
            }
            //加严类型4
            else if (ApprenStrictItemstr[1] == "04") {
              _this.CheckTypeNameplus = "全检";
              _this.form.SamplePlan2AC = "0/1";
              _this.fff = false;
              _this.ggg = true;
            } else {
              _this.valueTimeRange = "2h";
              _this.CheckTypeNameplus = "正常抽样计划";
              Toast.clear();

            }
          } else {
            _this.valueTimeRange = "2h";
            _this.CheckTypeNameplus = "正常抽样计划";
            // _this.eee = true;
            // _this.ddd1 = true;
            _this.fff = false;
            Toast.clear();
          }
          _this.getCheckType();
        } else {
          Toast.fail("未查询到相关数据");
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    async getDataByMaterial(val) {
      //alert(val);
      var _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      // alert( _this.form.ProductionAmount);
      // alert( _this.form.materialid);
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/QualitySampleData/GetDataByMaterial?MaterialID=" +
          _this.form.materialid +
          "&OutputAmount=" +
          _this.form.ProductionAmount
        );
        //alert(JSON.stringify(res.Data));
        if (res.HttpCode === "200") {
          Toast.clear();
          //若加严
          if (val == 0) {
            // AC/RE
            //alert(1);
            _this.form.SamplePlan2AC =
              res.Data.QualitySampleRules[0].StrictAcre;
            //抽样数量
            _this.form.PlanBox = res.Data.QualitySampleRules[0].StrictData;
            //alert(res.Data.QualitySampleRules[0].StrictData);
          } else if (val == 1) {
            //alert(JSON.stringify(res.Data));
            //alert(2);
            // AC/RE
            _this.form.SamplePlan2AC = res.Data.QualitySampleRules[0].Acre;
            //抽样数量
            _this.form.PlanBox = res.Data.QualitySampleRules[0].StrictData;
            //alert(res.Data.QualitySampleRules[0].StrictData);
          } else if (val == 2) {
            // AC/RE
            _this.form.SamplePlan2AC = "1/2";
            //抽样数量
            //_this.form.PlanBox = res.Data.QualitySampleRules[0].SampleData;
          }
          else if (val == 3) {
            // AC/RE
            _this.form.SamplePlan2AC = "0/1";
            //抽样数量
            //_this.form.PlanBox = res.Data.QualitySampleRules[0].SampleData;
          }
          else if (val == 4) {
            _this.form.SamplePlan2AC =
              res.Data.QualitySampleRules[0].Acre;
            //抽样数量
            _this.form.PlanBox = res.Data.QualitySampleRules[0].SampleData;
          }

        } else {
          Toast.fail("未查询到计划抽样数量");
        }
      } catch (e) {
        Toast.fail("未查询到计划抽样数量");
      }
    },
    //获取生产车间与缺陷信息方法
    getWorkshopIDandSampleData(machineID, materialid) {
      this.getWorkshopID(machineID);
      this.getSampleData(materialid);
    },
    //获取生产车间
    async getWorkshopID(machineID) {
      var _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/PLineEquipment/GetList?FactoryID=" +
          "TC00" +
          "&PLineID=" +
          machineID
        );
        if (res.HttpCode === "200" && res.Total > 0) {
          _this.form.WorkshopID = res.Data[0].WorkshopID;
        } else {
          Toast.fail("未查询到生产车间");
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取缺陷信息
    async getSampleData(materialid) {
      var _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/QualitySampleData/GetList?FactoryID=" +
          _this.FactoryID
          +
          "&MaterialID=" +
          materialid
        );
        // alert(_httpClient.getApiPrefix() +
        //   "/QualitySampleData/GetList?FactoryID=" +
        //   _this.FactoryID +
        //   "&MaterialID=" +
        //   materialid)
        //(JSON.stringify(res))
        if (res.HttpCode === "200" && res.Total > 0) {
          //抽样计划1G
          _this.form.SamplePlan1G = res.Data[0].HvyG;
          //抽样计划1Re
          _this.form.SamplePlan1Re = res.Data[0].HvyRe;
          //抽样计划2G
          _this.form.SamplePlan2G = res.Data[0].GenG;
          //抽样计划2AC
          //_this.form.SamplePlan2AC = res.Data[0].GenAeRe;
          //抽样计划2AQL
          _this.form.SamplePlan2AQL = res.Data[0].GenAQL;
          _this.form.PlanBox = res.Data[0].SampleAmount;
        } else {
          alert("未查询到当前产品抽样计划数据模板！");
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取班组信息
    async getteam() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/Team/GetList?FactoryID=" +
          _this.FactoryID
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            teamId: item.TeamID,
            teamName: item.TeamName,
          }));
          _this.columnsteamId = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取审核人信息
    async getCheckedMan() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/Employee/GetList?PositionID=GW08"
        );
        if (res.HttpCode === "200") {
          let checkedManMap = res.Data.map((item) => ({
            checkedManId: item.EmployeeID,
            checkedManName: item.EmployeeName,
          }));
          _this.columnsCheckedMan = checkedManMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    onConfirmCheckedMan(value, index) {
      this.form.CheckedMan = this.columnsCheckedMan[index].checkedManName;
      this.CheckedManName = this.columnsCheckedMan[index].checkedManName;
      this.showPickerCheckedMan = false;
    },
    checkAuditTime(startTime, endTime) {
      // 获取当前时间
      const date = new Date()
      // 获取当前时间的年月日
      const dataStr = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} `

      // 获取开始时间、结束时间、现在时间的时间戳
      let startDate = new Date(dataStr + startTime).getTime()
      let endDate = new Date(dataStr + endTime).getTime()
      let nowDate = date.getTime()

      const s = startDate > endDate // 判断开始时间否大于结束时间

      if (s) [startDate, endDate] = [endDate, startDate] // 若开始时间否大于结束时间则交换值

      // 判断现在的时间是否在开始时间和结束时间之间，若s为true则结果取反
      if (nowDate > startDate && nowDate < endDate) {
        return s ? false : true
      } else {
        return s ? true : false
      }
    },
    //获取班次信息
    async getshift() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/ProductionShift/GetActiveList?Actived=1"
        );
        if (res.HttpCode === "200") {
          let shiftMap = res.Data.map((item) => ({
            pshiftname: item.PShiftName + " " + item.BeginTime,
            pShiftID: item.PShiftID,
            BeginTime: item.BeginTime,
          }));
          _this.columnsshift = shiftMap;
          if (_this.checkAuditTime('08:30', '20:30')) {
            _this.valuepShiftName = _this.columnsshift[0].pshiftname;
            _this.form.pShiftID = _this.columnsshift[0].pShiftID;
            _this.BeginTime = _this.columnsshift[0].BeginTime;
          }
          else {
            _this.valuepShiftName = _this.columnsshift[1].pshiftname;
            _this.form.pShiftID = _this.columnsshift[1].pShiftID;
            _this.BeginTime = _this.columnsshift[1].BeginTime;
          }
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取时间范围
    async getTimeRange() {
      let _this = this;
      try {
        // let res = await _httpClient.get(
        //   _httpClient.getApiPrefix() + "/TimeRange/GetList?TimeFrom=" + _this.query.TimeFrom
        // );
        //if (res.HttpCode === "200") {
        var timeRangeNameMapdata = [
          {
            "TimeRangeID": "不选",
            "TimeRangeName": "不选",
          },
          {
            "TimeRangeID": "0.5h",
            "TimeRangeName": "0.5h",
          },
          {
            "TimeRangeID": "1h",
            "TimeRangeName": "1h",
          },
          {
            "TimeRangeID": "2h",
            "TimeRangeName": "2h",
          }
        ];
        let timeRangeNameMap = timeRangeNameMapdata.map((item) => ({
          TimeRangeName: item.TimeRangeName,
        }));
        _this.columnsTimeRangeName = timeRangeNameMap;


        var timeRangeNameMapdataplus = [
          {
            "TimeRangeID": "0:30",
            "TimeRangeName": "0:30",
          },
          {
            "TimeRangeID": "1:30",
            "TimeRangeName": "1:30",
          },
          {
            "TimeRangeID": "2:30",
            "TimeRangeName": "2:30",
          },
          {
            "TimeRangeID": "3:30",
            "TimeRangeName": "3:30",
          },
          {
            "TimeRangeID": "4:30",
            "TimeRangeName": "4:30",
          },
          {
            "TimeRangeID": "5:30",
            "TimeRangeName": "5:30",
          },
          {
            "TimeRangeID": "6:30",
            "TimeRangeName": "6:30",
          }
          ,
          {
            "TimeRangeID": "7:30",
            "TimeRangeName": "7:30",
          },
          {
            "TimeRangeID": "8:30",
            "TimeRangeName": "8:30",
          }
          ,
          {
            "TimeRangeID": "9:30",
            "TimeRangeName": "9:30",
          }
          ,
          {
            "TimeRangeID": "10:30",
            "TimeRangeName": "10:30",
          }
          ,
          {
            "TimeRangeID": "11:30",
            "TimeRangeName": "11:30",
          }
          ,
          {
            "TimeRangeID": "12:30",
            "TimeRangeName": "12:30",
          }
          ,
          {
            "TimeRangeID": "13:30",
            "TimeRangeName": "13:30",
          }
          ,
          {
            "TimeRangeID": "14:30",
            "TimeRangeName": "14:30",
          }
          ,
          {
            "TimeRangeID": "15:30",
            "TimeRangeName": "15:30",
          }
          ,
          {
            "TimeRangeID": "16:30",
            "TimeRangeName": "16:30",
          }
          ,
          {
            "TimeRangeID": "17:30",
            "TimeRangeName": "17:30",
          }
          ,
          {
            "TimeRangeID": "18:30",
            "TimeRangeName": "18:30",
          }
          ,
          {
            "TimeRangeID": "19:30",
            "TimeRangeName": "19:30",
          }
          ,
          {
            "TimeRangeID": "20:30",
            "TimeRangeName": "20:30",
          }
          ,
          {
            "TimeRangeID": "21:30",
            "TimeRangeName": "21:30",
          }
          ,
          {
            "TimeRangeID": "22:30",
            "TimeRangeName": "22:30",
          }
          ,
          {
            "TimeRangeID": "23:30",
            "TimeRangeName": "23:30",
          }
        ];
        let timeRangeNameMapplus = timeRangeNameMapdataplus.map((item) => ({
          TimeRangeName: item.TimeRangeName,
        }));

        _this.columnsTimeRangeNameplus = timeRangeNameMapplus;


      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    onConfirmTimeRange(value, index) {
      this.valueTimeRange = this.columnsTimeRangeName[index].TimeRangeName;
      if (this.valueTimeRange != "不选") {
        this.ddd = true;
      }
      else {
        this.ddd = false;
      }
      this.showPickerTimeRangeName = false;
      this.getCheckType();
    },
    MinutesTest1(val) {
      var sdate1 = new Date(val);
      sdate1.setMinutes(sdate1.getMinutes() + 30);
      var now = sdate1.getHours() + ":" + sdate1.getMinutes();
      return now;
    },
    MinutesTest2(val) {
      var sdate1 = new Date(val);
      sdate1.setMinutes(sdate1.getMinutes() + 60);
      var now = sdate1.getHours() + ":" + sdate1.getMinutes();
      return now;
    },
    MinutesTest3(val) {
      var sdate1 = new Date(val);
      sdate1.setMinutes(sdate1.getMinutes() + 120);
      var now = sdate1.getHours() + ":" + sdate1.getMinutes();
      return now;
    },
    onConfirmTimeRange11(value, index) {
      this.valueTimeRange11 = this.columnsTimeRangeName11[index].TimeRangeName;
      if (this.valueTimeRange == "0.5h") {
        this.valueTimeRange22 = this.MinutesTest1("1900-01-01 " + this.valueTimeRange11) + "0";
      } else if (this.valueTimeRange == "1h") {
        this.valueTimeRange22 = this.MinutesTest2("1900-01-01 " + this.valueTimeRange11);
      } else if (this.valueTimeRange == "2h") {
        this.valueTimeRange22 = this.MinutesTest3("1900-01-01 " + this.valueTimeRange11);
      } else {
        this.valueTimeRange22 = "";
      }

      this.showPickerTimeRangeName = false;
    },
    //获取一般缺陷原因
    async getQualityProblems() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/QualityProblems/GetList?SubClass=%E4%B8%80%E8%88%AC%E7%BC%BA%E9%99%B7"
        );

        if (res.HttpCode === "200") {
          var QProblem = {
            QProblemID: "0",
            QProblemName: "不选择"
          }
          _this.columnsQProblem.push(QProblem);
          let temp = res.Data.map((item) => ({
            QProblemID: item.QProblemID,
            QProblemName: item.QProblemName,
          }));
          temp.forEach((item) => {
            _this.columnsQProblem.push(item);
          });
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取严重缺陷
    async getManageReasonID() {
      let _this = this;
      var QProblem = {
        ManageReasonID: "0",
        ManageReasonName: "不选择"
      }
      _this.columnsManageReason.push(QProblem);
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/QualityProblems/GetList?SubClass=%E4%B8%A5%E9%87%8D%E7%BC%BA%E9%99%B7"
        );
        if (res.HttpCode === "200") {
          let temp = res.Data.map((item) => ({
            ManageReasonID: item.QProblemID,
            ManageReasonName: item.QProblemName,
          }));
          temp.forEach((item) => {
            _this.columnsManageReason.push(item);
          });
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //判断加严管控
    async getAddStrictManage() {
      let _this = this;

      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
          "/AddStrictManage/GetList?Closed=false&Checked=true"
        );
        if (res.HttpCode === "200") {
          for (let i = 0; i < res.Data.length; i++) {
            if (res.Data[i].PLineID == _this.plineID) {
              alert(
                "生产线:" +
                _this.plineID +
                "已处于加严管控状态。" +
                "请注意选择检验类型!"
              );
              _this.showPickerType = false;
              return;
            } else {
              _this.showPickerType = false;
            }
          }
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    ShowPickerdatetime() {
      // if (this.form.pShiftID == "") {
      //   alert("请先选择班次！")
      // } else {
      this.showPickerdatetime = true;
      // }
    },
    async getCheckType() {
      let _this = this;
      if (_this.valueTimeRange == "不选") {
        _this.sss1 = true;
        try {
          let res = await _httpClient.get(
            _httpClient.getApiPrefix() +
            "/QualityCheckType/GetList?Memo=%E5%A4%96%E8%A7%82%E6%A3%80%E9%AA%8C%E7%B1%BB%E5%9E%8B"
          );
          if (res.HttpCode === "200") {
            let shiftMap = res.Data.map((item) => ({
              CheckTypeName: item.CheckTypeName,
              CheckTypeID: item.CheckTypeID,
            }));
            shiftMap.pop();
            _this.columnsType = shiftMap;
          }
        } catch (e) {
          Toast.fail(JSON.stringify(e));
        }
      } else {
        var sss = "";
        _this.sss2 = true;
        if (this.valueTimeRange == "0.5h") {
          // let shiftMap = [
          //   { CheckTypeName: "正常抽样计划", CheckTypeID: "AP01-01" },
          //   { CheckTypeName: "增加每箱检测数量", CheckTypeID: "AP01-02" },
          //   { CheckTypeName: "每垛取一箱或一层，每箱/层全检", CheckTypeID: "AP01-03" },
          //   { CheckTypeName: "全检", CheckTypeID: "AP01-04" },
          // ];
          _this.columnsType = shiftMap;
        }
        else if (this.valueTimeRange == "1h") {
          // let shiftMap = [
          //   { CheckTypeName: "正常抽样计划", CheckTypeID: "AP02-01" },
          //   { CheckTypeName: "增加每箱检测数量", CheckTypeID: "AP02-02" },
          //   { CheckTypeName: "每垛取一箱或一层，每箱/层全检", CheckTypeID: "AP02-03" },
          //   { CheckTypeName: "全检", CheckTypeID: "AP02-04" },
          // ];
          _this.columnsType = shiftMap;
        }
        else if (this.valueTimeRange == "2h") {
          // let shiftMap = [
          //   { CheckTypeName: "正常抽样计划", CheckTypeID: "AP03-01" },
          //   { CheckTypeName: "增加每箱检测数量", CheckTypeID: "AP03-02" },
          //   { CheckTypeName: "每垛取一箱或一层，每箱/层全检", CheckTypeID: "AP03-03" },
          //   { CheckTypeName: "全检", CheckTypeID: "AP03-04" },
          // ];
          _this.columnsType = shiftMap;
        }
      }
    },
    itemClear() {
      this.form.valueteamid = "";
      this.form.pShiftID = "";
      this.form.pOrderID = "";
      this.form.materialid = "";
      this.form.materialname = "";
      this.form.planworkdatetime = "";
      this.form.ProductionDate = "";
      this.form.CheckTypeID = "";
      this.form.CheckedMan = "";
      //包装条码
      this.form.BarCode = "";
      //检验备注
      this.form.Memo = "";
      this.form.ProductionAmount = "";
      //抽样数量
      this.form.SampleAmount = "";
      //计划抽样数量
      this.form.PlanBox = "";
      //抽样计划1G
      this.form.SamplePlan1G = "";
      //抽样计划1Re
      this.form.SamplePlan1Re = "";
      //抽检值1
      this.form.SamplePlan1Value = 0;
      //抽样计划2G
      this.form.SamplePlan2G = "";
      //抽样计划2AC
      this.form.SamplePlan2AC = "";
      //抽样计划2AQL
      this.form.SamplePlan2AQL = "";
      //抽检值2
      this.form.SamplePlan2Value = 0;
      //生产批次
      this.form.BatchID = "";
      //生产车间
      this.form.WorkshopID = "";
      //检验是否合格
      this.form.QualityOk = "";
      //缺陷原因
      this.form.QProblemID = "0"; //管理责任
      this.form.ManageReasonID = "0";
      //客户名称
      this.form.CustomerName = "";
      this.showPickerdatetime = false;
      this.valueQualityOk = "1";
      this.plineID = "";
      this.ManageReasonName = "无异常";
      this.time = "";
      this.FactoryID = "";
      this.valuepShiftName = "";
      this.CheckTypeName = "";
      this.QProblemName = "无异常";
      this.valueteamid = "";
      this.BeginTime = "";
      this.WorkPlanDatetimeFrom = "";
      this.columnsteamId = [];
      this.showPickerteamid = false;
      this.showPickerpShiftID = false;
      this.valueemployid = "";
      this.columnsshift = [];
      this.columnsType = [];
      this.showPickerdatetime = false;
      this.showPickerType = false;
      this.showPickerManageReason = false;
      this.showPickerQProblem = false;
    },
    onConfirmpShiftID(value, index) {
      this.valuepShiftName = this.columnsshift[index].pshiftname;
      this.form.pShiftID = this.columnsshift[index].pShiftID;
      this.BeginTime = this.columnsshift[index].BeginTime;
      this.showPickerpShiftID = false;
      if (this.form.ProductionDate != "") {
        this.timeChange();
      }
    },
    onConfirmteamid(value, index) {
      this.form.valueteamid = this.columnsteamId[index].teamId;
      this.valueteamid = this.columnsteamId[index].teamName;
      this.showPickerteamid = false;
    },
    judgetype() {
      this.form.CheckTypeID = this.columnsType[index].CheckTypeID;
      this.CheckTypeName = this.columnsType[index].CheckTypeName;
      this.showPickerType = false;
      //如果加严
      //alert(this.form.CheckTypeID);
      if (this.valueTimeRange == "不选") {
        if (
          this.form.CheckTypeID == "CT03" ||
          this.form.CheckTypeID == "CT04" ||
          this.form.CheckTypeID == "CT05"
        ) {
          this.getDataByMaterial(1);
        } else {
          this.getDataByMaterial(0);
        }
      }
      else {
        if (this.form.CheckTypeID == "AP01-01" || this.form.CheckTypeID == "AP02-01" || this.form.CheckTypeID == "AP03-01") {
          //this.getDataByMaterial(1);
          this.getDataByMaterial(4);
        }
        else if (this.form.CheckTypeID == "AP01-02" || this.form.CheckTypeID == "AP02-02" || this.form.CheckTypeID == "AP03-02") {
          this.getDataByMaterial(0);
        }
        else if (this.form.CheckTypeID == "AP01-03" || this.form.CheckTypeID == "AP02-03" || this.form.CheckTypeID == "AP03-03") {
          this.getDataByMaterial(2);
        }
        else if (this.form.CheckTypeID == "AP01-04" || this.form.CheckTypeID == "AP02-04" || this.form.CheckTypeID == "AP03-04") {
          this.getDataByMaterial(3);
        }
      }
    },
    setonConfirmtype() {
      //alert(1);
      // alert(this.columnsType[index].CheckTypeID);
      // this.form.CheckTypeID = this.columnsType[index].CheckTypeID;
      // this.CheckTypeName = this.columnsType[index].CheckTypeName;
      // this.showPickerType = false;
      //如果加严
      //alert(this.valueTimeRange);
      if (this.valueTimeRange == "不选") {
        if (
          this.form.CheckTypeID == "CT03" ||
          this.form.CheckTypeID == "CT04" ||
          this.form.CheckTypeID == "CT05"
        ) {
          this.getDataByMaterial(1);
        } else {
          this.getDataByMaterial(0);
        }
      }
      else {
        //alert(this.doworkitem);
        if (this.doworkitem == "AP01-01" || this.doworkitem == "AP02-01" || this.doworkitem == "AP03-01") {
          this.getDataByMaterial(4);
        }
        else if (this.doworkitem == "AP01-02" || this.doworkitem == "AP02-02" || this.doworkitem == "AP03-02") {
          this.getDataByMaterial(0);
        }
        else if (this.doworkitem == "AP01-03" || this.doworkitem == "AP02-03" || this.doworkitem == "AP03-03") {
          this.getDataByMaterial(2);
        }
        else if (this.doworkitem == "AP01-04" || this.doworkitem == "AP02-04" || this.doworkitem == "AP03-04") {
          this.getDataByMaterial(3);
        }
      }
    },
    onConfirmtype(value, index) {
      this.form.CheckTypeID = "AP03-01"
      this.CheckTypeName = "正常抽样计划";
      this.showPickerType = false;
      //如果加严
      //alert(this.form.CheckTypeID);
      if (this.valueTimeRange == "不选") {
        if (
          this.form.CheckTypeID == "CT03" ||
          this.form.CheckTypeID == "CT04" ||
          this.form.CheckTypeID == "CT05"
        ) {
          this.getDataByMaterial(1);
        } else {
          this.getDataByMaterial(0);
        }
      }
      else {
        if (this.form.CheckTypeID == "AP01-01" || this.form.CheckTypeID == "AP02-01" || this.form.CheckTypeID == "AP03-01") {
          this.getDataByMaterial(4);
        }
        else if (this.form.CheckTypeID == "AP01-02" || this.form.CheckTypeID == "AP02-02" || this.form.CheckTypeID == "AP03-02") {
          this.getDataByMaterial(0);
        }
        else if (this.form.CheckTypeID == "AP01-03" || this.form.CheckTypeID == "AP02-03" || this.form.CheckTypeID == "AP03-03") {
          this.getDataByMaterial(2);
        }
        else if (this.form.CheckTypeID == "AP01-04" || this.form.CheckTypeID == "AP02-04" || this.form.CheckTypeID == "AP03-04") {
          this.getDataByMaterial(3);
        }
      }
    },
    onConfirmQProblem1(value, index) {
      // alert(1);
      this.form.QProblemID = this.columnsQProblem[index].QProblemID;
      this.QProblemName1 = this.columnsQProblem[index].QProblemID + "-" + this.columnsQProblem[index].QProblemName;
      this.QProblemIDList[0] = this.columnsQProblem[index].QProblemID + "-" + this.columnsQProblem[index].QProblemName;
      this.showPickerQProblem1 = false;
      // if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
      //   this.valueQualityOk = "1";
      //   this.form.QualityOk = true;
      // } else {
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
    },
    onConfirmQProblem2(value, index) {
      this.form.QProblemID = this.columnsQProblem[index].QProblemID;
      this.QProblemName2 = this.columnsQProblem[index].QProblemID + "-" + this.columnsQProblem[index].QProblemName;
      this.QProblemIDList[1] = this.columnsQProblem[index].QProblemID + "-" + this.columnsQProblem[index].QProblemName;
      this.showPickerQProblem2 = false;
      // if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
      //   this.valueQualityOk = "1";
      //   this.form.QualityOk = true;
      // } else {
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
    },
    onConfirmQProblem3(value, index) {
      this.form.QProblemID = this.columnsQProblem[index].QProblemID;
      this.QProblemName3 = this.columnsQProblem[index].QProblemID + "-" + this.columnsQProblem[index].QProblemName;
      this.QProblemIDList[2] = this.columnsQProblem[index].QProblemID + "-" + this.columnsQProblem[index].QProblemName;
      this.showPickerQProblem3 = false;
      // if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
      //   this.valueQualityOk = "1";
      //   this.form.QualityOk = true;
      // } else {
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
    },
    onConfirmManageReason1(value, index) {
      this.form.ManageReasonID = this.columnsManageReason[index].ManageReasonID;
      this.ManageReasonName1 = this.columnsManageReason[index].ManageReasonID + "-" + this.columnsManageReason[index].ManageReasonName;
      this.ManageReasonIDList[0] = this.columnsManageReason[index].ManageReasonID + "-" + this.columnsManageReason[index].ManageReasonName;
      this.showPickerManageReason1 = false;
      // if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
      //  this.valueQualityOk = "1";
      //   this.form.QualityOk = true;
      // } else {
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
    },
    onConfirmManageReason2(value, index) {
      this.form.ManageReasonID = this.columnsManageReason[index].ManageReasonID;
      this.ManageReasonName2 = this.columnsManageReason[index].ManageReasonID + "-" + this.columnsManageReason[index].ManageReasonName;
      this.ManageReasonIDList[1] = this.columnsManageReason[index].ManageReasonID + "-" + this.columnsManageReason[index].ManageReasonName;
      this.showPickerManageReason2 = false;
      // if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
      //   this.valueQualityOk = "1";
      //   this.form.QualityOk = true;
      // } else {
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
    },
    onConfirmManageReason3(value, index) {
      this.form.ManageReasonID = this.columnsManageReason[index].ManageReasonID;
      this.ManageReasonName3 = this.columnsManageReason[index].ManageReasonID + "-" + this.columnsManageReason[index].ManageReasonName;
      this.ManageReasonIDList[2] = this.columnsManageReason[index].ManageReasonID + "-" + this.columnsManageReason[index].ManageReasonName;
      this.showPickerManageReason3 = false;
      // if (this.form.QProblemID == "0" && this.form.ManageReasonID == "0") {
      //   this.valueQualityOk = "1";
      //   this.form.QualityOk = true;
      // } else {
      //   this.valueQualityOk = "0";
      //   this.form.QualityOk = false;
      // }
    },
    onConfirmdatetime(time) {
      this.time = time;
      this.form.ProductionDate = `${time.getFullYear()}-${time.getMonth() + 1
        }-${time.getDate()}`;
      this.showPickerdatetime = false;
    },
    // 获取当前时间
    getNowTime() {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      dateTime = yy + "-" + mm + "-" + dd;
      return dateTime;
    },
    timeChange() {
      const strArr = this.BeginTime.split(":");
      this.form.planworkdatetime = `${this.time
        .getFullYear()
        .toString()
        .padStart(2, 0)}-${(this.time.getMonth() + 1)
          .toString()
          .padStart(2, 0)}-${this.time.getDate().toString().padStart(2, 0)} ${strArr[0]
        }:${strArr[1]}:${strArr[2]}`;
    },
    //确认提交表单
    async submitsure() {
      var _this = this;
      if (_this.isMustShowScanner2 && _this.countNum > 0) {
        Toast.fail("此产品代码为5必须扫描包装条码！");
        return;
      }
      var manageReasonID = _this.form.ManageReasonID;
      var qProblemID = _this.form.QProblemID;

      if (manageReasonID == "") {
        Toast.fail("有非填字段");
        return;
      } else if (manageReasonID == "0") {
        _this.ManageReasonIDList = "";
      }
      if (qProblemID == "") {
        Toast.fail("有非填字段");
        return;
      } else if (qProblemID == "0") {
        _this.QProblemIDList = "";
      }

      if (_this.valueQualityOk == "1") {
        _this.form.QualityOk = true;
      } else {
        //若不合格 填写抽检表单
        _this.form.QualityOk = false;
      }
      var sampleAmount = _this.form.SamplePerBox * _this.form.SampleBox;
      //时间+8还是有问题 直接传字符串也行
      //var workPlanDatetimeFrom = new Date(this.form.planworkdatetime);

      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "请稍等...",
      });

      if (_this.CheckTypeNameplus == "全检") {
        _this.form.BoxInBatch = "0";
      }
      var bodyitem = {
        //本批生产箱数/垛数
        BoxInBatch: _this.form.BoxInBatch,
        //每垛/箱抽SamplePerBox检数量
        SamplePerBox: _this.form.SamplePerBox,
        //每箱/垛数量
        CountPerBox: _this.form.CountPerBox,
        //抽检垛/箱数量
        SampleBox: _this.form.SampleBox,
        //计划抽检垛/箱数
        PlanBox: _this.form.PlanBox,
        //生产日期
        ProductionDate: _this.form.ProductionDate,
        workshopID: _this.form.WorkshopID,
        PLineID: _this.plineID,
        checkTypeID: _this.form.CheckTypeID,
        qualityOk: _this.form.QualityOk,
        QProblemID: JSON.stringify(_this.QProblemIDList),
        barCode: JSON.stringify(_this.BarCodeLsit),
        Memo: _this.form.Memo,
        POrderID: _this.form.pOrderID,
        MaterialID: _this.form.materialid,
        MaterialName: _this.form.materialname,
        customerName: _this.form.CustomerName,
        //目标检测数量 生产数量
        productionAmount: _this.form.ProductionAmount,
        checkedMan: _this.form.CheckedMan,
        sampleAmount: sampleAmount,
        samplePlan1G: _this.form.SamplePlan1G,
        samplePlan1Re: _this.form.SamplePlan1Re,
        samplePlan1Value: _this.form.SamplePlan1Value,
        samplePlan2G: _this.form.SamplePlan2G,
        samplePlan2AC: _this.form.SamplePlan2AC,
        samplePlan2AQL: _this.form.SamplePlan2AQL,
        samplePlan2Value: _this.form.SamplePlan2Value,
        BatchID: _this.form.BatchID,
        TeamID: _this.form.valueteamid,
        PShiftID: _this.form.pShiftID,
        factoryID: "TC00",
        //班次开始日期
        workPlanDatetimeFrom: _this.form.planworkdatetime,
        ManageReasonID: JSON.stringify(_this.ManageReasonIDList),
        creator: _this.user.userName,
        createDatetime: "",
        TimeRangeID: _this.valueTimeRange,
        deleteFlag: false,
        ImageURL1: String(_this.equipRepairVo1.picList),
        ImageURL2: String(_this.equipRepairVo2.picList)
      };


      let item3 = []
      if (this.ManageReasonName1 != "" && !this.ManageReasonName1.includes("不选择") && !this.ManageReasonName1.includes("无异常")) {
        item3.push(this.ManageReasonName1)
      }
      if (this.ManageReasonName2 != "" && !this.ManageReasonName2.includes("不选择") && !this.ManageReasonName2.includes("无异常")) {
        item3.push(this.ManageReasonName2)
      }
      if (this.ManageReasonName3 != "" && !this.ManageReasonName3.includes("不选择") && !this.ManageReasonName3.includes("无异常")) {
        item3.push(this.ManageReasonName3)
      }

      if (this.QProblemName1 != "" && !this.QProblemName1.includes("不选择") && !this.QProblemName1.includes("无异常")) {
        item3.push(this.QProblemName1)
      }

      if (this.QProblemName2 != "" && !this.QProblemName2.includes("不选择") && !this.QProblemName2.includes("无异常")) {
        item3.push(this.QProblemName2)
      }

      if (this.QProblemName3 != "" && !this.QProblemName3.includes("不选择") && !this.QProblemName3.includes("无异常")) {
        item3.push(this.QProblemName3)
      }

      // alert(JSON.stringify(bodyitem));
      // alert(JSON.stringify(item3));
      // Toast.clear();
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/QualityAppearanceCheck/SaveEntity",
          {
            body: bodyitem,
          }
        );
        // alert(JSON.stringify(res))
        //alert(JSON.stringify(res));
        if (res.Message != null) {
          //message不为空,有报错信息，打卡失败 暂时这样判断
          Toast.clear();
          alert(JSON.stringify(res));
        } else {
          //打卡成功
          Toast.clear();
          Toast.success("保存成功！");

          if (!_this.form.QualityOk) {
            bodyitem.Id = res.Data;
            bodyitem.planworkdatetime = _this.form.planworkdatetime;
            _this.$ac.openWin({
              name: "quality-qCcheckApplicationNew",
              url: "./quality-qCcheckApplicationNew.html",
              // name: "quality-qCcheckApplication",
              // url: "./quality-qCcheckApplication.html",
              pageParam: {
                item: bodyitem,
                item2: bodyitem,
                item3: item3
              },
            });
          }

          setTimeout(function () {
            _this.$ac.closeWin();
          }, 2000);
        }
      } catch (e) {
        Toast.clear();
        alert(JSON.stringify(e));
      }
    },
  },
};
</script>

<style>
body {
  background-color: white;
}

.table-title-class {
  background-color: #304156;
  color: #fff;
}

.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.buttongroup {
  float: right;
  margin-right: 10px;
  margin-top: 10px;
  margin-bottom: 20px;
}

.container.dwo {
  display: flex;
  justify-content: center;
  align-items: center;
}

.buttonLeft {
  position: fixed;
  bottom: 8px;
  float: left;
  width: 49%;
}

.formstyle {
  margin-top: 8px;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
}

.formstyleplus {
  /* margin-top: 8px; */
  margin-left: 5px;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
}


.radioteam {
  display: flex;
  align-items: center;
  padding-left: 13px;
  margin-top: 10px;
  margin-left: 34px;
  margin-bottom: 10px;
}

.buttonRight {
  position: fixed;
  bottom: 8px;
  float: right;
  left: 51%;
  width: 49%;
  background-color: #f22028;
  border-color: #f22028;
}

.textScroll {
  display: inline-block;
  position: fixed;
  top: 50%;
  bottom: 3rem;
  overflow: scroll;
  right: 10px;
  width: 100%;
  z-index: 1;
}

.message {
  font-size: 15px;
  margin-top: 5px;
  margin-left: -10px;
  font-weight: bold;
}

.mg5 {
  margin-right: 5px;
}

.tag_margin {
  margin: 2px 5px;
}

.card_under {
  height: 100%;
  width: 100%;
  margin: auto;
  background: #ffffff;
  border-radius: 25px;
  box-shadow: 0 0px 0px rgba(0, 0, 0, 0.3);
}

.card_icon {
  text-align: center;
  /* position: absolute; */
  height: 8rem;
  width: 80%;
  margin: 12% 10%;
  background: rgba(35, 180, 237, 1);
  border-radius: 25px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
}

.text {
  font-size: 18px;
  color: #4e4a67;
  margin: 8px auto auto 20px;
  line-height: 1.5rem;
  text-align: justify;
  font-weight: 600;
}

.text_small {
  font-size: 16px;
  color: red;
  margin: 8px auto auto 20px;
  line-height: 1.5rem;
  text-align: justify;
  font-weight: 700;
}

.text_scan {
  font-size: 16px;
  color: #4e4a67;
  margin: auto auto auto 20px;
  line-height: 1.5em;
  text-align: justify;
}

.divStyle {
  margin-left: 3px;
  margin-right: 3px;
}

.rowTextArea::v-deep .van-field__value {
  border: 1px solid #ccc;
}

.divMessageplus {
  margin-top: 0px;
  border: solid #dcdcdc;
  /* margin-left: 5px;
  margin-right: 5px; */
  border-top-width: 3px;
  border-left-width: 3px;
  border-right-width: 3px;
  border-bottom-width: 3px;
}
</style>
